package com.yidian.dao;

import com.yidian.pojo.goods.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

/**
 * @author whb
 * @create 2021-05-25 10:32
 * @decription 库存量单位Mapper
 */
public interface SkuMapper extends Mapper<Sku> {
    /**
     * 扣减库存
     * @param id 商品skuId
     * @param num 购买数量
     */
    @Select("UPDATE tb_sku SET num=num-#{num} WHERE id=#{id}")
    public  void deductionStock(@Param("id") String id,@Param("num") Integer num);

    /**
     * 增加销量
     * @param id 商品skuId
     * @param num 购买数量
     */
    @Select("UPDATE tb_sku SET num=num+#{num} WHERE id=#{id}")
    public void addSaleNum(@Param("id") String id,@Param("num") Integer num);
}
